// $Id: conversions.h 56 2007-05-31 20:18:18Z DarkAn9el $
/***************************************************************************
 *   Copyright (C) 2007 by Andrea Blankenstijn, Ulrich Giraud              *
 *   <darkan9el@gmail.com>, <blade.124@laposte.net>                        *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

#ifndef CONVERSIONS_H
#define CONVERSIONS_H

#include <cmath>
#include <cctype>
#include <iostream>
#include <map>
#include <stdint.h> // type C99 intmax_t
#include <string>

#ifndef MAIN_H
  using namespace std;
  double error(const string& s);
#endif

/**
 * \class Conversions conversions.h
 * \brief Pour faciliter le travaille, en interne
 * tout les calcules sont effectué en base 10. Cette classe
 * permet la conversion vers, ou de la base 10.
 */

class Conversions
{
public:

  const std::string DecToX(double nb, unsigned short to_base);
  double XToDec(char *c_nb, unsigned short from_base);

private:

  unsigned short base; ///< base de calcule
  short flag; ///< nombre de sortie pour l'affichage
  unsigned short ** nb_table; ///< nombre décomposé en chiffre
  char* p_nb; ///< pointeur sur le nombre entré par l'utilisateur.
  unsigned short size[2]; ///< nombre de chiffre de in_nb après et avant la virgule

  inline unsigned short CheckChar(char to_check);
  inline short ConvertChar(char c_nb);
  void ParseChar();
  void Size();
};

#endif
